<template>
    <div class="app-container">
      <el-form ref="elForm" size="mini" :model="form" :rules="rules" label-width="120px">
        <el-row>
          <el-col :span="24">
            <el-form-item label="公司名称" prop="base_name">
              <el-input v-model="form.base_name" placeholder="请输入公司名称" />
            </el-form-item>
          </el-col>

          <el-col :span="24">
            <el-form-item label="公司介绍" prop="base_remark">
              <editor :height="300" v-model="form.base_remark"></editor>
            </el-form-item>
          </el-col>

        </el-row>
      </el-form>

      <div slot="footer" class="dialog-footer" style="text-align: right;">
        <el-button size="mini" type="primary" @click="submitForm">确 定</el-button>
      </div>
    </div>
</template>

<script>
  import { getCompany, updateCompany } from "@/api/base/banner";
  export default {
        name: "conpanyForm",
        data() {
          return{
            menuOptions: [],
            form: {
              base_name: '',
              base_remark: ''
            },
            // 表单校验
            rules: {
              base_name: [
                { required: true, message: "轮播图名称不能为空", trigger: "blur" }
              ],
              banner_url: [
                { required: true, message: "轮播图不能为空", trigger: "blur,change" }
              ],
            }
          }
        },
      mounted() {
          getCompany(1).then(res=>{
            this.form = res.data;
          });
      },
      methods:{
          getImgUrl(val){

          },
          // 确定
          submitForm(){
            this.$refs['elForm'].validate((valid) => {
              if (valid) {
                updateCompany(this.form).then(res=>{
                    this.commonMsg(res.code);
                  });
              } else {
                return;
              }
            });
          },
          // 取消
          cancel(){
            this.$emit('cancelForm');
          },
          // 公共提示
          commonMsg(code) {
            if(code == 200) {
              this.$message.success('操作成功.');
              getCompany(1).then(res=>{
                this.form = res.data;
              });
            } else {
              this.$message.error(res.msg);
            }
          }
        }
    }
</script>

<style scoped>

</style>
